var discount = {

};

//课程列表
discount.list = function(){	
	openLoad();
    var args = getQueryStringArgs(),
    	discountType = args["discountType"];
    
    if(discountType==="2"){
    	document.title="一口价";
    	$(".aui-car-white-Typeface").html('一口价');
    }   
    else{
    	document.title="折扣价";
    	$(".aui-car-white-Typeface").html("折扣价");
    } 
    	
    var options = {    	
    	discountType:discountType,    	
        courseStatus:"1",
        current:1,
        size:999
    };
    var ajax = new $ax(Feng.ctxPath+"/activity/selectParam", function(data){
    	Feng.log("课程信息查询成功");
    	if(data.success){
    		if(data.obj.length === 0 ){
    			closeLoad();
    			tipSearchNull(".aui-myOrder-content");
    			return;
    		}
    		
    		//图片过滤器
	        template.helper('pictureFormat', function (inp) {
	           if(inp){
	               return Feng.ctxPath+"/file/getImage/"+inp;
	           }
	           else{
	               return "themes/img/pd/course_defult.jpg";
	           }
	        });
	        //价格
	        template.helper('coursePriceFormat', function (inp) {
	            if(inp!==""){
	                return numeral(inp).format('0,0.00');
	            }
	        });
	        if(discountType==="2"){
				var outHtml = template("dataTmpl",data.obj);
	        	$(".tab-panel-item").html(outHtml);	        	
	        }
	        else{
	        	//价格
		        template.helper('dateFormat', function (inp) {
		            if(inp!==""){
		                return inp.split(' ')[0];
		            }
		        });
	        	
	        	var outHtml = template("dataTmpl2",data.obj);
	        	$(".tab-panel-item").html(outHtml);	
	        }
	         
	        
    	}    
    	else{
    		tipSearchNull(".aui-myOrder-content");
    	}
        closeLoad();
    },function(data){
    	closeLoad();
    	tipSearchNull(".aui-myOrder-content");
        Feng.error("加载信息失败!");
    });
    ajax.setData(options);
    ajax.start();
};

$(function(){
	discount.list();
	
	lazyloadImg();
});
